package com.zhengqing.design.structure.proxy._01;

import com.zhengqing.design.structure.proxy._01.service.JdbcService;
import com.zhengqing.design.structure.proxy._01.service.impl.JdbcServiceImpl;

/**
 * <p> 代理类 </p>
 *
 * @author zhengqingya
 * @description 减少 JdbcServiceImpl 对象加载的内存占用
 * @date 2022/12/22 10:00
 */
public class JdbcProxy implements JdbcService {

    JdbcServiceImpl jdbcServiceImpl;

    @Override
    public void selectOne() {
        if (this.jdbcServiceImpl == null) {
            System.out.println("加载...");
            this.jdbcServiceImpl = new JdbcServiceImpl();
        }
        this.jdbcServiceImpl.selectOne();
    }
}
